<template>
	<rich-text :nodes="content"></rich-text>
	
</template>

<script>
	export default {
		data() {
		    return {
				content: '',
		    }
		},
		onLoad() {
			this.getData();
		},
		methods: {
			getData () {
				let that = this;
				this.$api.getPost({label: 'about'}).then((res) => {
					that.content = that.formatRichText(res.data.content);
				}).catch(res => {
					console.log(res)
				})
			},
			
			formatRichText(html) {
				//控制小程序中图片大小
				let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
					console.log(match.search(/style=/gi));
					if (match.search(/style=/gi) == -1) {
						match = match.replace(/\<img/gi, '<img style=""');
					}
					return match;
				});
	
				newContent = newContent.replace(/style="/gi, '$& max-width:100% !important; ');
				newContent = newContent.replace(/<br[^>]*\/>/gi, '');
				return newContent;
			},
		}
	}
</script>

<style>
	
/deep/ img {
		width: 100%;
}
	
</style>
